<?php
/**
 * 应用配置
 */

namespace app\api\controller;


use app\api\model\Adver as AdverModel;
use app\api\model\AppConfig;
use app\api\model\IntervalConfig;
use app\api\model\Region;
use app\common\controller\ApiController;
use think\Exception;

class Config extends ApiController {

    protected $notNeedToken = ['getlist'];
    protected $notNeedPhone = ['getlist'];

    /**
     * 系统配置
     * @return false|string
     */
    public function getList() {
        try {
            $params = $this->checkParams('');
            if ($params === false) {
                return $this->resErr();
            }
            $user_agreement = config('global.user_agreement');//用户协议
            $privacy_agreement = config('global.privacy_agreement');//隐私政策
            $house_advert = '不限购可贷款';
            $map_house=config('global.map_house');//地图找房附近多少距离（公里）的房源
            AppConfig::get_data($data1, $data2, $data3);
            $distance = 1000;//地图找房滑动多少米请求一次接口
            $app_version=config('global.app_version');

            $headers=$this->headers;
            if ($headers['os']==1){
                //ios
                $ios_version['ios']=$app_version['ios'];
                $app_version=$ios_version;
            }else{
               //安卓
                foreach ($app_version as $k =>$v){
                    unset($app_version['ios']);
                }
            }
            return $this->resData('success', compact('distance', 'user_agreement', 'privacy_agreement', 'house_advert','map_house','app_version','data1', 'data2', 'data3'));
        } catch (Exception $e) {
            return $this->resErr($e->getMessage(), $e->getCode());
        }
    }

}
